<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of CreateReceivingOrder
 *
 * @author Administrator
 */
class OutStock extends CI_Controller
{

    function __construct()
    {
        parent::__construct();
        $this->load->service('/wms/inventory_service');
                $this->load->service('wms/api_service');
    }
    function out_stock()
    {
  /**      
        $lstProduct = array(
            array(
                'orderId' => 'wx9705566',
                'sku' => '02010012-0069',
                'whsCode' => 'S001-W1',
                'quantity' => '1'),
            array(
                'orderId' => 'wx9705566',
                'sku' => '05010000-0074',
                'whsCode' => 'S001-W1',
                'quantity' => '1')
        );
        $time = time();
        $user = 'tomrepair.es';
        $password = 'omstomrepaires20161214';
        $token = md5($user . $time . $password);
        $request = array(
            'user' => $user,
            'timestamp' => $time,
            'sign' => $token,
            'data' => $lstProduct
        );
        echo json_encode($request);exit;
   * 
   */
        $gp = json_decode(file_get_contents('php://input'), true);
        $authorized = $this->api_service->checkAuthorized($gp);
        $lstProduct=$gp['data'];
        $skuArray = array();
        foreach ($lstProduct as $productInfo)
        {
            $one['sku'] = $productInfo['sku'];
            $one['whsCode'] = $productInfo['whsCode'];
            $one['quantity'] = $productInfo['quantity'];
            $one['refNum'] = $productInfo['orderId'];
            $one['comments'] = $productInfo['comments'];
            $skuArray[] = $one;
        }
        $rs = $this->inventory_service->out_stock_array_t($skuArray);
        echo json_encode($rs);
    }

}

?>
